#include "comm.hpp"

int main()
{
    std::cout<<"client begin"<<std::endl;
    int wfd = open(NAME_PIPE,O_WRONLY);
    std::cout<<"cliet end"<<std::endl;
    if(wfd < 0)
    {
        exit(1);
    }

    char buffer[1024];
    while(true)
    {
        std::cout<<"please say# "<<std::endl;
        fgets(buffer ,sizeof buffer, stdin);
        if(strlen(buffer)>0)
        {
            // 从键盘输入的时候会默认带带一个\n
            buffer[strlen(buffer)-1]=0;
        }

        // 写数据

        ssize_t n =write(wfd,buffer,strlen(buffer));
        assert(n==strlen(buffer));
        (void) n;
    }
    close(wfd);
    return 0;
}